package com.awardsystem.Service;

import com.awardsystem.Dao.UserDao;
import com.awardsystem.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserDao userDao;

    public User findUserByNumber(String number){return userDao.findByNumber(number);}
    public void addUser(User user){userDao.save(user);}
    public List<User> getAllUsers(){return userDao.findAll();}
    public User findByPersonNameAndCorp(String personName,String corp){
        return userDao.findByPersonNameAndCorp(personName,corp);
    }
    public User findUserByPersonName(String personname){
        return userDao.findUserByPersonName(personname);
    }
    public User findUserById(Integer id){return userDao.findUserById(id);}
    public void deleteUser(User user){
        userDao.delete(user);
    }

    public List<User> getUsersByName(String name){return userDao.findByPersonNameContains(name);}
}
